/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pedigreereconstruction;

/**
 *
 * @author arthiramachandran
 */
public class Individual {

    public final String id;

    public Individual(String id) {
        this.id = id;
    }

    Individual() {
        this.id = null;
    }

    public String toString() {
        return id;
    }

    public double idNumber() {
        // TODO: this works for kosrae but might be different for other datasets; need a comparable class instead
        return (Double.parseDouble(id.substring(1)));
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Individual) {
            Individual i = (Individual) obj;
            /*if (i.id.contains("-")) {
                return (this.id.contains("-"));
            } 
              else {
             * 
             */
                return (i.id.equals(this.id));
            //}
        }

        return false;
    }

    @Override
    public int hashCode() {
        //if (this.isMissing())
          //  return "missing".hashCode();
        return this.id.hashCode();
    }

    public boolean isMissing() {
        return this.id.contains("-");
    }

    // TODO rename this function to be more accurate
    public boolean missingEquals(Individual obj) {
        if (obj instanceof Individual) {
            Individual i = (Individual) obj;
            return (i.id.equals(this.id));
        }

        return false;
    }
}
